/*
 *  Author: Rico Yang
 *  gcc version: (Ubuntu 9.3.0-10ubuntu2)
 */

#ifndef SEQLIST_H__
#define SEQLIST_H__

#include <stdio.h>
#include <stdlib.h>

// 去掉输入缓冲区中多余的字符包括换行等
#define eatline ({while(getchar()!='\n'){continue;}})

#define INIT_SIZE 8        // 表的初始大小
#define INCREASE_SIZE 10    // 表的增量
typedef int DataType;       // 预设的表元素的数据类型
typedef struct {
    DataType *data;         // 也可以写 DataType *data;
    int maxSize, lenth;     // 表的最大长度和当前已存元素个数
} SeqList;

short increaseSize(SeqList *list);
void initSeqList(SeqList *list);
void displaySeqList(SeqList *list);
void clearSeqList(SeqList *list);
void isEmpty(SeqList *list);
void isFull(SeqList *list);
short insertAtTheEnd(SeqList *list, DataType userData);
short insertAtTheBeginning(SeqList *list, DataType userData);
short insertByLocation(SeqList *list, int location, DataType userData);
short insertByArray(SeqList *list);
void getListLenth(SeqList *list);
short popAtTheEnd(SeqList *list);
short popAtTheBeginning(SeqList *list);
short popByLocation(SeqList *list, int location);
short popByData(SeqList *list, DataType userData);
int getLocationByData(SeqList *list, DataType userData);
DataType getDataByLocation(SeqList *list, int location);
void sortList(SeqList *list);
void reverseList(SeqList *list);
void destroyList(SeqList *list);

void mergeToNewLists(SeqList *dest, SeqList *srcLA, SeqList *srcLB);
void mergeWithoutDup(SeqList *srcLA, SeqList *srcLB);

#endif